#ifndef TREE_H
#define TREE_H
#include "treenode.h"
class Tree{
public:
    inline TreeNode *getRootNode(){ return root;}
    Tree(TreeNode *_root):root(_root),alloc_in_function(false){}
    Tree(int val){
        TreeNode *node = new TreeNode(val);
        root = node;
        alloc_in_function = true;
    }
    virtual ~Tree(){
        if(alloc_in_function)
            delete root;
    }
    TreeNode *getParent(TreeNode *node);
    static TreeNode *getParent(Tree *t, TreeNode *node);
    int getDeepth();
    static int getDeepth(Tree *t);
    int getWidth();
    static int getWidth(Tree *t);
protected:
    TreeNode *root;
    bool alloc_in_function;
};

#endif // TREE_H
